<?php
declare (strict_types=1);

namespace app\user\model\user;

use app\common\logic\Attach;
use app\common\model\BaseModel;

/**
 * Class PersonalData
 *
 * @package app\user\model\user
 */
class PersonalData extends BaseModel
{

    /**
     * 表名
     *
     * @var string
     */
    protected $name = 'site_personal_data';

    /**
     * 定义表主键
     *
     * @var string
     */
    protected $pk = 'id';

    protected $globalScope = ['mhm'];

    /**
     * 时间显示格式
     *
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i';

    public function scopeMhm($query)
    {
        $query->where('mhm_id', request()->mhm_id);
    }

    public function iconUrl()
    {
        return $this->belongsTo(Attach::class, 'icon', 'id')->bind(['icon_url' => 'fileurl']);
    }
}